/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cashmate.struts;

import com.cashmate.hibernate.dao.UserTypeDAO;
import com.cashmate.hibernate.pojo.Usertypes;
import com.opensymphony.xwork2.ActionSupport;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

/**
 *
 * @author Dine
 */
@Action(value = "/select-usertypes", results = {
    @Result(name = "success", location = "../fragments/usertypes.jsp"),
    @Result(name = "error", location = "../error/messages.jsp")})
public class ForGridSelectUsertypes extends ActionSupport {

    private List<Usertypes> utypeList;
    private final UserTypeDAO utype = (UserTypeDAO) ServletActionContext.getServletContext().getAttribute("usertypeDAO");
    private static Logger logger = Logger.getLogger(ForGridSelectUsertypes.class);

    @Override
    public String execute() {
        try {
            utypeList = utype.getAll();
            return SUCCESS;
        } catch (Exception e) {
            logger.fatal(e.getMessage(),e);
            return ERROR;
        }
    }

    public List<Usertypes> getUtypeList() {
        return utypeList;
    }
}
